#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    setclickType(0);
    QFile styleFile(":///qss/style.qss");
    styleFile.open(QIODevice::ReadOnly);
    QString strStyle(styleFile.readAll());
    setStyleSheet(strStyle); //setclickType(1);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::setclickType(int clicktype)
{
    nclicktype=clicktype;
}

int Widget::getclickType() const
{
    return nclicktype;
}


void Widget::on_pushButton_clicked()
{
    nclicktype++;
    setclickType(nclicktype%=3);
     ui->label_8->setText(QString::number(nclicktype));
     ui->label_8->show();
     ui->label_2->setProperty("sceneSelect", true);
     style()->unpolish(ui->label_2);
     style()->polish(ui->label_2);
     style()->unpolish(ui->label_3);
     style()->polish(ui->label_3);
     update();
}

void Widget::paintEvent(QPaintEvent *)
{
//    QFile styleFile(":///qss/style.qss");
//    styleFile.open(QIODevice::ReadOnly);
//    QString strStyle(styleFile.readAll());
//   setStyleSheet(strStyle);
    QStyleOption opt;
    opt.init(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);


}
